import { configureStore } from '@reduxjs/toolkit'
import category from './slice/category'
import detail from './slice/picture'
import { PagerResponse } from '../api'
import publicPicture from './slice/publicPicture'
import favorite from './slice/favorite'
import user from './slice/user'

export interface AsyncState {
  status: 'idle' | 'loading' | 'succeeded' | 'failed',
  error: string | null
}
export interface ListState<T> {
  list: T[]
  pager:PagerResponse
}
const store = configureStore({
  reducer: {
    user,
    category,
    favorite,
    detail,
    publicPicture,
  }
})

// 从 store 本身推断出 `RootState` 和 `AppDispatch` 类型
export type RootState = ReturnType<typeof store.getState>
// 推断出类型: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch

export default store